package top.swimmer.tools.data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class NewBracket {
    static List<String> brackets = new ArrayList<>();
    public static void newBracket(String prefix, int preNum, int nextNum) {
        if (nextNum == 0) {
            brackets.add(prefix);
            return;
        }

        if (nextNum == preNum) {
            newBracket(prefix + "(", preNum - 1, nextNum);
        } else if (preNum < nextNum) {
            if (preNum != 0) {
                newBracket(prefix + "(", preNum - 1, nextNum);
            }
            newBracket(prefix + ")", preNum, nextNum - 1);
        }
    }

    public static List<String> newBracket(int num) {
        if (num <= 0) {
            return Collections.emptyList();
        }
        newBracket("", num, num);
        return brackets;
    }

    public static void main(String[] args) {
        System.out.println(newBracket(3));
    }
}
